#ifndef ROOM_MEDIA_COMMAND_IN_H_
#define ROOM_MEDIA_COMMAND_IN_H_
#include "command.h"

#pragma pack(1)
namespace Cmd
{
        namespace RoomMedia
        {
                //  cmd declaration
                enum {
                        CMDIN_LOGIN             = 0x0001,	// 其他服务器连接RoomMediaServer验证
                        CMDIN_FUNC              = 0x0002,	// 内部功能指令
                };
                enum { //CMDIN_LOGIN
                        SCMDIN_LOGIN                            = 0x0001,
                        SCMDIN_LOGIN_RESPONCE                   = 0x0002,
                };
                enum { //CMDIN_FUNC
                        SCMDIN_REQ_RELAY_ADDR                   = 0x0001,
                        SCMDIN_RES_RELAY_ADDR                   = 0x0002,
                        SCMDIN_REQ_ENGINE_ADDR                  = 0x0003,
                        SCMDIN_RES_ENGINE_ADDR                  = 0x0004,
                        SCMDIN_ADD_ROOM                         = 0x0005,
                        SCMDIN_ADD_ROOM_RES                     = 0x0006,
                        SCMDIN_DEL_ROOM                         = 0x0007,
                        SCMDIN_ADD_USER                         = 0x0008,
                        SCMDIN_ADD_USER_RES                     = 0x0009,
                        SCMDIN_DEL_USER                         = 0x000A,
                        SCMDIN_SET_USER_SPEAK                   = 0x000B,
                        SCMDIN_ADD_USERS                        = 0x000C,
                        SCMDIN_MUTE_MEDIA_DATA              = 0x000D,  // enable/disable media data.
                };

                //	cmd definition
                struct stLoginCmd:t_NullCmd
                {
                        stLoginCmd():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN)
                        {
                                server_type_ = 0;
                                server_id_ = 0;
                                dest_type_ = ROOMMEDIASERVER;
                        }
                        WORD server_type_;
                        DWORD server_id_;
                        WORD dest_type_;
                };
                struct stLoginResponce:t_NullCmd
                {
                        stLoginResponce():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RESPONCE)
                        {
                        }
                };

                // cmd func
                struct stFuncReqRelayAddr:
                        t_NullCmd
                {
                        stFuncReqRelayAddr():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_REQ_RELAY_ADDR)
                        {
                        }
                };
                struct stFuncResRelayAddr:
                        t_NullCmd
                {
                        stFuncResRelayAddr():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_RES_RELAY_ADDR)
                        {
                                server_id_ = 0;
                                bzero(ip_, sizeof(ip_));
                                port_ = 0;
                        }
                        WORD server_id_;
                        char ip_[MAX_IP_LENGTH+1];
                        WORD port_;
                };
                struct stFuncReqEngineAddr:
                        t_NullCmd
                {
                        stFuncReqEngineAddr():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_REQ_ENGINE_ADDR)
                        {
                        }
                };
                struct stFuncResEngineAddr:
                        t_NullCmd
                {
                        stFuncResEngineAddr():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_RES_ENGINE_ADDR)
                        {
                                engine_ip_ = 0;
                                engine_port_ = 0;
                        }
                        DWORD engine_ip_;
                        WORD engine_port_;
                };
                struct stFuncAddRoom:
                        t_NullCmd
                {
                        stFuncAddRoom():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_ADD_ROOM)
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stFuncAddRoomRes:
                        t_NullCmd
                {
                        stFuncAddRoomRes():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_ADD_ROOM_RES)
                        {
                                room_id_ = 0;
                                ret_code_ = 0;
                        }
                        DWORD room_id_;
                        BYTE ret_code_; //0-fail; 1-success
                };
                struct stFuncDelRoom:
                        t_NullCmd
                {
                        stFuncDelRoom():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_DEL_ROOM)
                        {
                                room_id_ = 0;
                        }
                        DWORD room_id_;
                };
                struct stFuncAddUser:
                        t_NullCmd
                {
                        stFuncAddUser():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_ADD_USER)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        uint8_t  dev_type_;
                };
                struct stFuncAddUserRes:
                        t_NullCmd
                {
                        stFuncAddUserRes():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_ADD_USER_RES)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                ret_code_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        BYTE ret_code_; //0-fail; 1-success
                };
                struct stFuncDelUser:
                        t_NullCmd
                {
                        stFuncDelUser():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_DEL_USER)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                };
                struct stFuncSetUserSpeak:
                        t_NullCmd
                {
                        stFuncSetUserSpeak():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_SET_USER_SPEAK)
                        {
                                room_id_ = 0;
                                user_id_ = 0;
                                state_ = 0;
                        }
                        DWORD room_id_;
                        DWORD user_id_;
                        BYTE state_; //0-mute, 1-speak
                };
                struct stFuncAddUsers:
                        t_NullCmd
                {
                        stFuncAddUsers():
                                t_NullCmd(CMDIN_FUNC, SCMDIN_ADD_USERS)
                        {
                                room_id_ = 0;
                                size_ = 0;
                        }
                        DWORD room_id_;
                        WORD size_;
                        DWORD list_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this)+size_*sizeof(list_[0]);
                        }
                };

                struct stDisableMediaData : t_NullCmd
                {
                        stDisableMediaData() :
                                t_NullCmd(CMDIN_FUNC, SCMDIN_MUTE_MEDIA_DATA)
                        {
                                room_id = 0;                                
                        }

                        uint32_t room_id;
                        uint32_t user_id;
                        uint8_t data_type;
                        uint8_t enable;  // 0 -- disable, 1 -- enable
                };

        }; //namespace RoomMedia
}; //namespace Cmd
#pragma pack() //pack(1)

#endif //ROOM_MEDIA_COMMAND_IN_H_
